import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { UserService } from 'src/app/service/user.service';

@Component({
  selector: 'app-inverhistory',
  templateUrl: './inverhistory.component.html',
  styleUrls: ['./inverhistory.component.scss'],
  providers: [UserService]
})
export class InverhistoryComponent implements OnInit {
  uid: any;
  status = 'all';
  pageIndex = 1;
  pageSize = 15;
  total = 1;
  dataSet = [];
  loading = true;
  isOkLoading = false;
  isVisible = false;
  starttime: any;
  endtime: any;
  statuslist = [{ key: 'all', value: '全部' }, { key: false, value: '邀请中' }, { key: true, value: '邀请成功' }];
  constructor(private service: UserService, private ar: ActivatedRoute) {
    this.uid = this.ar.snapshot.params.id;
  }
  ngOnInit() {
    this.searchData();
  }

  searchData(reset: boolean = false): void {
    this.loading = true;
    this.service.queryinver({
      offset: this.pageIndex,
      limit: this.pageSize,
      uid: this.uid,
      status: this.status,
      starttime: this.starttime,
      endtime: this.endtime
    }).then((res) => {
      this.loading = false;
      this.total = res.total;
      this.dataSet = res.rows;
    });
  }

}
